<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
  Created by IntelliJ IDEA.
  User: wjc
  Date: 2021/4/11
  Time: 14:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>橡树科技－JavaDemoSystem</title>
    <!-- 引入 Bootstrap -->
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <!-- jQuery (Bootstrap 的 JavaScript 插件需要引入 jQuery) -->
    <script src="https://code.jquery.com/jquery.js"></script>
    <link type="text/css" rel="stylesheet" media="all" href="/static/styles/global.css" />
    <link type="text/css" rel="stylesheet" media="all" href="/static/styles/global_color.css" />

    <script language="javascript" type="text/javascript">
        //排序按钮的点击事件
        function sort(btnObj) {
            location.href="/fee/fee_list?"+"field="+btnObj.name+"&sort="+btnObj.className;
        }

        //启用
        function startFee(obj) {
            if(window.confirm("确定要启用此资费吗？资费启用后将不能修改和删除。")){
                $.ajax({
                    url:'${pageContext.request.contextPath}/fee/enable',
                    type:'POST',
                    data:{"costId":obj},
                    success:function(ret){
                        if(ret.code == "0"){
                            if(confirm(ret.message + " 点击确认跳转")){
                                location.href="/fee/fee_list";
                            }
                        }else {
                            alert(ret.message);
                        }
                    }
                });
            }
        }
        //删除
        function deleteFee(obj) {
            if(window.confirm("确定要删除此资费吗？")){
                $.ajax({
                    url:'${pageContext.request.contextPath}/fee/delete',
                    type:'POST',
                    data:{"costId":obj},
                    success:function(ret){
                        if(ret.code == "0"){
                            if(confirm(ret.message + "点击确认跳转")){
                                location.href="/fee/fee_list";
                            }
                        }else {
                            alert(ret.message);
                        }
                    }
                });
            };
        }
    </script>
    <style type="text/css">
        a, a:hover, a:focus {
            text-decoration: none;
        }
    </style>
</head>
<body>

<div id="header">
    <img src="/static/images/logo.png"  alt="logo" class="left"/>
    <a href="/logout">[退出]</a>
</div>


<div id="navi">
    <ul id="menu">
        <li><a href="${pageContext.request.contextPath}/index" class="index_on"></a></li>
        <c:forEach items="${list}" var="c">
            <li><a href="${pageContext.request.contextPath}/${c.url}" class="index_on"></a></li>
        </c:forEach>
        <li><a href="user/user_info.html" class="information_off"></a></li>
        <li><a href="user/user_modi_pwd.html"  class="password_off"></a></li>
    </ul>
</div>


<div id="main">
    <form action="" method="">

        <div class="search_add">
            <div>
                <input type="button" name="UNIT_COST" value="单费" class="${field == 'UNIT_COST'? (sort == 'sort_desc'? 'sort_asc':'sort_desc'):'sort_asc'}" onClick="sort(this);"/>
                <input type="button" name="BASE_COST" value="基费" class="${field == 'BASE_COST'?  (sort == 'sort_desc'? 'sort_asc':'sort_desc'):'sort_asc'}" onClick="sort(this);"/>
                <input type="button" name="BASE_DURATION" value="时长" class="${field == 'BASE_DURATION'?  (sort == 'sort_desc'? 'sort_asc':'sort_desc'):'sort_asc'}" onClick="sort(this);"/>
            </div>
            <input type="button" value="增加" class="btn_add" onClick="location.href='/fee/add';"/>
        </div>

        <div id="operate_result_info" class="operate_success">
            <img src="/static/images/close.png" onClick="this.parentNode.style.display='none';"/>
            删除成功！
        </div>

        <div id="data">
            <table id="datalist">
                <tr>
                    <th>资费ID</th >
                    <th class="width100">资费名称</th>
                    <th>基本时长</th>
                    <th>基本费用</th>
                    <th>单位费用</th>
                    <th>创建时间</th>
                    <th>开通时间</th>
                    <th class="width50">状态</th>
                    <th class="width200"></th>
                </tr>
                <c:forEach items="${pageInfo.list}" var="cost">
                    <tr>
                        <td>${cost.costId}</td>
                        <td><a href="/fee/detail?costId=${cost.costId}" >${cost.name}</a></td>
                        <td>${cost.baseDuration}</td>
                        <td>${cost.baseCost}</td>
                        <c:if test="${empty cost.unitCost}">
                            <td></td>
                        </c:if>
                        <c:if test="${not empty cost.unitCost}">
                            <td>${cost.unitCost} 元/小时</td>
                        </c:if>
                        <td><fmt:formatDate value="${cost.creatime}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></td>
                        <td><fmt:formatDate value="${cost.startime}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></td>
                        <c:if test="${cost.status eq '1'}">
                            <td>暂停</td>
                            <td>
                                <input type="button" value="启用" class="btn_start" onClick="startFee(${cost.costId});"/>
                                <input type="button" value="修改" class="btn_modify" onClick="location.href='/fee/modi?costId='+ ${cost.costId};"/>
                                <input type="button" value="删除" class="btn_delete" onClick="deleteFee(${cost.costId});"/>
                            </td>
                        </c:if>
                        <c:if test="${cost.status != '1'}">
                            <td>开通</td>
                            <td></td>
                        </c:if>
                    </tr>
                </c:forEach>
            </table>
            <p>业务说明：<br/>
                1、创建资费时，状态为暂停，记载创建时间；<br/>
                2、暂停状态下，可修改，可删除；<br/>
                3、开通后，记载开通时间，且开通后不能修改、不能再停用、也不能删除；<br/>
                4、业务账号修改资费时，在下月底统一触发，修改其关联的资费ID（此触发动作由程序处理）
            </p>
        </div>

        <div id="pages">
            <c:if test="${pageInfo.total >= 1}">
                <c:if test="${!pageInfo.isFirstPage}">
                    <a  href="/fee/fee_list?pageNum=${pageInfo.pageNum-1}&field=${field}&sort=${sort}">上一页</a>
                </c:if>
                <c:if test="${pageInfo.isFirstPage}">
                    <a  href="javascript:void(0)">上一页</a>
                </c:if>
                <c:forEach begin="1" end="${pageInfo.pages}" var="i">
                    <a href="/fee/fee_list?pageNum=${i}&field=${field}&sort=${sort}" class="${pageInfo.pageNum == i ? "current_page" : ""}">${i}</a>
                </c:forEach>
                <c:if test="${!pageInfo.isLastPage}">
                    <a  href="/fee/fee_list?pageNum=${pageInfo.pageNum+1}&field=${field}&sort=${sort}">下一页</a>
                </c:if>
                <c:if test="${pageInfo.isLastPage}">
                    <a  href="javascript:void(0)">下一页</a>
                </c:if>
            </c:if>
        </div>

    </form>
</div>

<div id="footer">
    <p>[源自橡树的技术，最优秀的师资，最真实的企业环境，最适用的实战项目]</p>
    <p>版权所有(C)橡树信息科技有限公司 </p>
</div>
</body>
</html>
